#include <cstdio>
#include <queue>

using namespace std;

struct Node
{
    int x, y;
    Node( ) { }
    Node( int _x, int _y )
        : x( _x ), y( _y ) { }
};

int n, m, count;
bool wall[ 1501 ][ 1501 ];
int color[ 1501 ][ 1501 ], head, tail;
Node q[ 1502 * 1502 ];

void init( )
{
    int i, j;
    char s[ 1001 ];
    for ( i = 0; i < 3 * n; i++ )
        for ( j = 0; j < 3 * m; j++ )
        {
            color[ i ][ j ] = -1;
            wall[ i ][ j ] = false;
        }
    for ( i = 0; i < n; i++ )
    {
        scanf("%s", s);
        for ( j = 0; j < m; j++ )
            if ( s[ j ] == '/' )
                wall[ 3 * i ][ 3 * j + 2 ] = wall[ 3 * i + 1 ][ 3 * j + 1 ] = wall [ 3 * i + 2 ][ 3 * j ] = true;
            else
                wall[ 3 * i ][ 3 * j ] = wall[ 3 * i + 1 ][ 3 * j + 1 ] = wall[ 3 * i + 2 ][ 3 * j + 2 ] = true;;
    }
}

void bfs( int x, int y )
{
    Node p;
    head = 0;
    tail = -1;
    q[ ++tail ] = Node( x, y );
    while ( head <= tail )
    {
        p = q[ head++ ];
        if ( p.x < 0 || p.x >= 3 * n || p.y < 0 || p.y >= 3 * m )
            continue;
        if ( color[ p.x ][ p.y ] != -1 || wall[ p.x ][ p.y ] )
            continue;
        color[ p.x ][ p.y ] = count;
        q[ ++tail ] = Node( p.x + 1, p.y );
        q[ ++tail ] = Node( p.x - 1, p.y );
        q[ ++tail ] = Node( p.x, p.y + 1 );
        q[ ++tail ] = Node( p.x, p.y - 1 );
    }
}

void work( )
{
    int i, j;
    count = 0;
    for ( i = 0; i < 3 * n; i++ )
        for ( j = 0; j < 3 * m; j++ )
            if ( !wall[ i ][ j ] && color[ i ][ j ] == -1 )
            {
                bfs( i, j );
                count++;
            }
    count = 0;
    for ( i = 0; i < n; i++ )
        for ( j = 0; j < m; j++ )
            if ( wall[ i * 3 ][ j * 3 ] && color[ i * 3 ][ j * 3 + 2 ] == color[ i * 3 + 2 ][ j * 3 ] )
                count++;
            else
                if ( wall[ i * 3 ][ j * 3 + 2 ] && color[ i * 3 ][ j * 3 ] == color[ i * 3 + 2 ][ j * 3 + 2 ] )
                    count++;
    printf("%d\n", count);
                
}

int main( )
{
    while ( scanf("%d%d", &m, &n) != EOF )
    {
        init( );
        work( );
    }
    return 0;
}
